//
//  HomeLinkItemView.m
//  Btpin
//
//  Created by Vic on 2019/12/8.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "HomeLinkItemView.h"

@interface HomeLinkItemView ()
{
    UIImageView *imgView;
    UILabel *titleLbl;
    UILabel *detailLbl;
}
@end

@implementation HomeLinkItemView

- (instancetype)initWithFrame:(CGRect)frame homeLinkType:(HomeLinkType)type {
    self = [super initWithFrame:frame];
    if (self) {
        [self initUIWithType:type];
        self.homeLinkType = type;
    }
    return self;
}
- (void)initUIWithType:(HomeLinkType)type {
    CGFloat y = 0;
    CGFloat width = ScalePS(25);
    CGFloat height = width;
    UIImage *img = [UIImage new];
    NSString *title = @"";
    NSString *detail = @"";
    switch (type) {
        case HomeLinkTypeOfJobPromotion: {
            img = [UIImage imageNamed:@"h_link_jobpromotion_icon"];
            y = (self.frame.size.height-img.size.height)*0.5;
            title = @"职位推广";
            detail = @"快速找到合适人才";
        } break;
        case HomeLinkTypeOfBusinessCard: {
            img = [UIImage imageNamed:@"h_link_businesscard_icon"];
            y = (self.frame.size.height-img.size.height)*0.5;
            title = @"职场名片";
            detail = @"链接更多人脉";
        } break;
        case HomeLinkTypeOfInvite: {
            img = [UIImage imageNamed:@"h_link_invite_icon"];
            y = (self.frame.size.height-img.size.height)*0.5;
            title = @"邀请用户";
            detail = @"聘豆赚不停";
        } break;
        case HomeLinkTypeOfCreditHashRate: {
            img = [UIImage imageNamed:@"h_link_jobpromotion_icon"];
            y = (self.frame.size.height-img.size.height)*0.5;
            title = @"信用算力";
            detail = @"开启简历赚钱";
        } break;
        default:
            break;
    }
    imgView = [UIToolsControl initImageViewWithFrame:CGRectMake(0, y, width, height) imageName:nil];
    imgView.contentMode = UIViewContentModeScaleAspectFill;
    imgView.image = img;
    [self addSubview:imgView];
    imgView.userInteractionEnabled = NO;
    
    titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(imgView)+ScalePS(5), StartY(imgView)-ScalePS(3), self.frame.size.width-width-ScalePS(5), ScalePS(18)) text:title textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
    [self addSubview:titleLbl];
    titleLbl.userInteractionEnabled = NO;
    
    detailLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(titleLbl), EndY(titleLbl)+ScalePS(3), ViewWidth(titleLbl), ScalePS(13)) text:detail textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_11];
    [self addSubview:detailLbl];
    detailLbl.userInteractionEnabled = NO;
}

@end
